<style>
	.layui-form-label {
		width: 90px;
		padding-right: 15px;
	}
	.layui-inline input{
		width: 193px;
	}
</style>
<div class="layuimini-main layuimini-panel loukou loukou-config-rw">
	<div class="layui-row layui-col-space15 layui-form" lay-filter="form-high">
		<div class="layui-col-md6">
			<div class="layui-card">
				<div class="layui-card-header">高区</div>
				<div class="layui-card-body">
					<div class="">
						<div class="layui-form-item">
							<label class="layui-form-label">阀门控制模式</label>
							<div class="layui-inline">
								<select name="PIDEN0" lay-search="">
									<option value="">空</option>
									<option value="0">自动</option>
									<option value="1">手动</option>
									<option value="2">远程</option>
								</select>
							</div>
							<div class="layui-inline">
								<button type="button" class="layui-btn layui-btn-sm" id="PIDEN0">配置</button>
							</div>
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label">热表型号</label>
							<div class="layui-inline">
								<select name="HEATTYPE0" lay-search="">
									<option value="">空</option>
									<option value="0">CJ188</option>
									<option value="1">en1413</option>
									<option value="2">modbus</option>
								</select>
							</div>
							<div class="layui-inline">
								<button type="button" class="layui-btn layui-btn-sm" id="HEATTYPE0">配置</button>
							</div>
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label">阀门地址</label>
							<div class="layui-inline">
								<input type="text" name="HEATADDR0" autocomplete="off" placeholder="HEATADDR0" class="layui-input">
							</div>
							<div class="layui-inline">
								<button type="button" class="layui-btn layui-btn-sm" id="HEATADDR0">配置</button>
							</div>
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label">PID_Ki</label>
							<div class="layui-inline">
								<input type="text" name="PIDKI0" autocomplete="off" placeholder="PIDKI0" class="layui-input">
							</div>
							<div class="layui-inline">
								<button type="button" class="layui-btn layui-btn-sm" id="PIDKI0">配置</button>
							</div>
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label">PID_Kp</label>
							<div class="layui-inline">
								<input type="text" name="PIDKP0" autocomplete="off" placeholder="PIDKP0" class="layui-input">
							</div>
							<div class="layui-inline">
								<button type="button" class="layui-btn layui-btn-sm" id="PIDKP0">配置</button>
							</div>
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label">PID_Kd</label>
							<div class="layui-inline">
								<input type="text" name="PIDKD0" autocomplete="off" placeholder="PIDKD0" class="layui-input">
							</div>
							<div class="layui-inline">
								<button type="button" class="layui-btn layui-btn-sm" id="PIDKD0">配置</button>
							</div>
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label">PID_MIN</label>
							<div class="layui-inline">
								<input type="text" name="PIDMIN0" autocomplete="off" placeholder="PIDMIN0" class="layui-input">
							</div>
							<div class="layui-inline">
								<button type="button" class="layui-btn layui-btn-sm" id="PIDMIN0">配置</button>
							</div>
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label">PID_MAX</label>
							<div class="layui-inline">
								<input type="text" name="PIDMAX0" autocomplete="off" placeholder="PIDMAX0" class="layui-input">
							</div>
							<div class="layui-inline">
								<button type="button" class="layui-btn layui-btn-sm" id="PIDMAX0">配置</button>
							</div>
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label">PID_Des</label>
							<div class="layui-inline">
								<input type="text" name="PIDTEMPSET0" autocomplete="off" placeholder="PIDTEMPSET0" class="layui-input">
							</div>
							<div class="layui-inline">
								<button type="button" class="layui-btn layui-btn-sm" id="PIDTEMPSET0">配置</button>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
		<div class="layui-col-md6">
			<div class="layui-card">
				<div class="layui-card-header">低区</div>
					<div class="layui-card-body">
						<div class="">
							<div class="layui-form-item">
								<label class="layui-form-label">阀门控制模式</label>
								<div class="layui-inline">
									<select name="PIDEN1" lay-search="">
										<option value="">空</option>
										<option value="0">自动</option>
										<option value="1">手动</option>
										<option value="2">远程</option>
									</select>
								</div>
								<div class="layui-inline">
									<button type="button" class="layui-btn layui-btn-sm" id="PIDEN1">配置</button>
								</div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label">热表型号</label>
								<div class="layui-inline">
									<select name="HEATTYPE1" lay-search="">
										<option value="">空</option>
										<option value="0">CJ188</option>
										<option value="1">en1413</option>
										<option value="2">modbus</option>
									</select>
								</div>
								<div class="layui-inline">
									<button type="button" class="layui-btn layui-btn-sm" id="HEATTYPE1">配置</button>
								</div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label">阀门地址</label>
								<div class="layui-inline">
									<input type="text" name="HEATADDR1" autocomplete="off" placeholder="HEATADDR1" class="layui-input">
								</div>
								<div class="layui-inline">
									<button type="button" class="layui-btn layui-btn-sm" id="HEATADDR1">配置</button>
								</div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label">PID_Ki</label>
								<div class="layui-inline">
									<input type="text" name="PIDKI1" autocomplete="off" placeholder="PIDKI1" class="layui-input">
								</div>
								<div class="layui-inline">
									<button type="button" class="layui-btn layui-btn-sm" id="PIDKI1">配置</button>
								</div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label">PID_Kp</label>
								<div class="layui-inline">
									<input type="text" name="PIDKP1" autocomplete="off" placeholder="PIDKP1" class="layui-input">
								</div>
								<div class="layui-inline">
									<button type="button" class="layui-btn layui-btn-sm" id="PIDKP1">配置</button>
								</div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label">PID_Kd</label>
								<div class="layui-inline">
									<input type="text" name="PIDKD1" autocomplete="off" placeholder="PIDKD1" class="layui-input">
								</div>
								<div class="layui-inline">
									<button type="button" class="layui-btn layui-btn-sm" id="PIDKD1">配置</button>
								</div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label">PID_MIN</label>
								<div class="layui-inline">
									<input type="text" name="PIDMIN1" autocomplete="off" placeholder="PIDMIN1" class="layui-input">
								</div>
								<div class="layui-inline">
									<button type="button" class="layui-btn layui-btn-sm" id="PIDMIN1">配置</button>
								</div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label">PID_MAX</label>
								<div class="layui-inline">
									<input type="text" name="PIDMAX1" autocomplete="off" placeholder="PIDMAX1" class="layui-input">
								</div>
								<div class="layui-inline">
									<button type="button" class="layui-btn layui-btn-sm" id="PIDMAX1">配置</button>
								</div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label">PID_Des</label>
								<div class="layui-inline">
									<input type="text" name="PIDTEMPSET1" autocomplete="off" placeholder="PIDTEMPSET1" class="layui-input">
								</div>
								<div class="layui-inline">
									<button type="button" class="layui-btn layui-btn-sm" id="PIDTEMPSET1">配置</button>
								</div>
							</div>
						</div>
					</div>
			</div>
		</div>
	</div>
	</div>
	<div class="layui-btn-container loukou-config-btn">
		<button type="button" class="layui-btn layui-btn-normal" id='getconfig'>获取配置</button>
	</div>
	<div class="layui-btn-container loukou-config-btn">
		<button type="button" class="layui-btn layui-btn-normal" id='send-tou-chuan'>发送透传</button>
	</div>
</div>



<script>
	layui.use(['form', 'table'], function () {
		var form = layui.form,
			layer = layui.layer,
			table = layui.table,

			$ = layui.$;

		/**
		 * 初始化表单，要加上，不然刷新部分组件可能会不加载
		 */
		form.render();
		// 当前弹出层，防止ID被覆盖
		var parentIndex = layer.index;

		// //赋值
		// form.val('form-high', {
		// 	PIDEN0: 1,
		// 	PIDKI0: '1234'
		// })
		//取值 表单中所有值
		// var form_high = form.val('form-high')

		var btnfunc = {
			loadId: -1,
			ajax: function (url, data, type, callback) {
				$.ajax({
					url: url,
					type: type,
					data: data,
					dataType: 'json',
					beforeSend: function () { //当一个Ajax请求开始时触发
						btnfunc.loadId = layer.load();//,{content:'正在加载中....'}); //打开layui加载效果
					},
					success: function (data) {
						layer.close(btnfunc.loadId)
						callback(data)

					}, error: function (res) {
						console.log(res)
						layer.msg('请求失败', { icon: 2, time: 3000 })
						layer.close(btnfunc.loadId)
					}
				})
			},
			getconfig: function () {
				btnfunc.ajax('/xapi/loukouconfig', '', 'get', function (data) {
					if (data != null) {
						form.val('form-high', data)
					}
				})

			},

		}
		$('.loukou-config-rw').on('click', '.layui-btn', function () {
			var self = $(this)
			var id = self.attr('id')
			console.log(id)
			if (!Object.prototype.hasOwnProperty.call(btnfunc, id)) {
				layer.msg('当前按钮未绑定事件', { icon: 0, time: 3000 });
				return
			}
			btnfunc[id]()
		})
		btnfunc.getconfig()
	});
</script>